package zjitc.net.Servlet.User;

import zjitc.net.Daomain.User;
import zjitc.net.Service.UserService;
import zjitc.net.Service.imp.UserServiceImp;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: 赵诚挚
 * @Date: 2023/06/07/19:58
 * @Description:
 */
@WebServlet(name = "userDetailServlet", value = "/userDetailServlet")
public class DetailServlet extends UserServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        UserService userService1= new UserServiceImp();
        User user = userService1.FindUsernameAndPassword(username, password);
        req.setAttribute("user",user);
        RequestDispatcher dispatcher = req.getRequestDispatcher("/detail.jsp");
        dispatcher.forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
